package 算法基础模板.chapter_02;

import java.util.Stack;

/**
 * @author Summerday
 */
public class MoniStack {

    int[] stk;
    int top;

    MoniStack(int n) {
        stk = new int[n];
        top = 0;
    }

    boolean isEmpty() {
        return top <= 0;
    }

    void push(int x) {
        stk[ ++top] = x;
    }

    int pop() {
        if(isEmpty()){
            throw new RuntimeException();
        }
        return stk[top--];
    }

    boolean isFull() {
        return top == stk.length;
    }

    int peek() {
        if(isEmpty()){
            throw new RuntimeException();
        }
        return stk[top];
    }

}
